﻿using StackExchange.Redis;

namespace Canteen.Core.Common
{
    public class RedisCache
    {
        #region 构造函数
        public RedisCache(string ConnectionString)
            : this(ConfigurationOptions.Parse(ConnectionString)) { }
        public RedisCache(ConfigurationOptions options)
        {
            Connection = ConnectionMultiplexer.Connect(options);
        }
        #endregion
        public ConnectionMultiplexer Connection { get; }

        public IDatabase GetDatabase(int db = -1, object asyncState = null) => Connection.GetDatabase(db, asyncState);
        public bool IsConnecte => Connection.IsConnected;
    }
}